<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/pc/jsp/common/common.jsp"%>
<%@ page language="java" import="com.limao.DBDataClass.CrowdUserAuthClass"%>
<% 
  String userid=(String)CacheClass.isLogin(request,response);
 if(CacheClass.getIntValue(userid)==0)
 {
 	out.println("<script language='JavaScript'>alert('您还没有登陆！');location.href=document.referrer;</script>"); //后退并刷新
 } 
 CrowdUserAuthClass user= WebFunction.getUserInfo(request,response);
 if(user==null)
 {
	 out.println("<script language='JavaScript'>alert('用户不存在，或被平台禁用，请联系客服！');window.history.back(-1);</script>");
	 return;
 } 
%>

<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <title>申请提现</title>
    <link rel="stylesheet" href="js/validation/screen.css" />

    <script src="js/validation/jquery.validate.js"></script>
    <script src="js/validation/messages_zh.js"></script>
    <script>
		$(window).load(function() {
			headertabcurrent=6;
			$("#header").load("pc/header.jsp"); 
			$("#footer").load("pc/footer.jsp"); 
		});
	</script>
</head>
<body  ontouchstart="">
       <!--header-->
	<div  id="header"> </div>

    <div class="container jz bcf" style="margin-top: 18px;">
        <div class="w100 of bcf">
         <form  method="post" id="signupForm" action="" >
            <div class="fqzcTittle jz tc c3 f25 of clearfix">
                提现申请
            </div>
            <p class="c3 f20 tc" style="margin: 42px 0 4px;">可提现金额</p>
            <p id="allMoney" class="corange tc f30"><%=user.rmbforwith%></p>
             <p class="f15 c9 mgt10 tc">* 7个工作日内最多提现２次，每次提现金额为可用金额的40.0%</p>
            <div class="tixianData jz" style="width: 519px;margin-top: 25px;">
                <input type="text" name="moneyCash" id="moneyCash" placeholder="提现金额" class="applyInput f20 br6"/>
                <p class="t2 f12 cred"></p>
                 <input type="text" name="bankCard" id="bankCard" placeholder="银行卡号" class="applyInput f20 br6"/>
                <p class="t2 f12 cred"></p>
                 <input type="text" name="bankCardName" id="bankCardName" placeholder="银行卡户名" class="applyInput f20 br6"/>
                <p class="t2 f12 cred"></p> 
                <input type="text" name="openingBank" id="openingBank" placeholder="银行卡开户行及支行" class="applyInput f20 br6"/>
                <p class="t2 f12 cred"></p>
                <input type="text" name="openingBankPlace" id="openingBankPlace" placeholder="银行卡开户地，填市级（如：武汉市）" class="applyInput f20 br6"/>
                <p class="t2 f12 cred"></p>
                <input type="password" name="appPwd" id="appPwd" placeholder="本平台登陆密码" class="applyInput f20 br6"/>
                <p class="t2 f12 cred"></p>
                <input type="button" name="" id="sub" value="确认提现" onclick="Sub();" class="btnBlue cf tc f27 br3 db jz" style="width: 402px;height: 63px;line-height: 63px;margin-top: 43px;"/>
               
            </div>
            </form>
        </div>

    </div><!--container-->

	<!--footer-->
    <div id="footer" class="footer w100 of"></div>

<div id="loadingfDiv" class="loadingfDiv pf w100 h100 db">
    <div class="w100 h100">
        <img src="pc/images/loading.gif" class="db jz" style="margin-top: 40%;">
    </div>
</div><!--loadinfDiv-->
<script>

 var myValidator;
$().ready(function() {
		 var allMoney = $("#allMoney").text();
         var moneyLimit = (allMoney*0.4).toFixed(2);
	 	  myValidator=$("#signupForm").validate(
	 		{
	 			rules:{
	 				bankCard:{
	 					required: true,
	 					number:true,
                		rangelength:[16,19] 
  	 				},
	 				moneyCash:{
	 					required: true,
	 					number:true,
	 					min:1,
	 					max:moneyLimit
  	 				},
            		appPwd:
            		{
            			required:true,
            			rangelength:[6,20]
            		},
	 				bankCardName:
            		{
            			required:true,
            			rangelength:[2,10]
	 				},
	 				openingBank:
            		{
            			required:true,
            			minlength:2
	 				},
	 				openingBankPlace:
            		{
            			required:true,
            			minlength:2
	 				}
	 				
	 			},
	 			//errorElement: 'p',
                errorPlacement: function(error, element) {
                // Append error within linked label
	                $( element )
		                .closest( "form" )
		                .find( element )
		                .after( error);
	                },
	                errorElement: "p",
	                errorClass:"errorInfo",
		 		});
});

    function Sub() {
        if(myValidator.form()== false){
            alert("填写存在错误 ！");
            return false;
        }
         	var moneyCash = $.trim($('#moneyCash').val());
            var bankCard = $.trim($('#bankCard').val());
            var bankCardName = $.trim($('#bankCardName').val());
            var openingBank = $.trim($('#openingBank').val());
            var openingBankPlace = $.trim($('#openingBankPlace').val());
            var appPwd = $.trim($('#appPwd').val());
        
        $.ajax({
            url: "PlugServlet",
            data: JSON.stringify({m:215,rmb:moneyCash,password:$.md5(appPwd),cardtype:0,cardno:bankCard,cardname:bankCardName,cardbank:openingBank,cardarea: openingBankPlace}),
            type: 'post',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
                $(".theme-popover-mask").fadeIn();
                $("#successSub").fadeIn();
            },
            success: function (data) {
	             if(data['state']==1)
					alert("申请提交成功，工作人员二个工作日内审核！");
				 else
				  	alert(data.info);
            },
            error: function (data) {
                return false;
            },
            complete: function () {
                 $(".theme-popover-mask").fadeOut();
                $("#successSub").fadeOut();
            }
        });
    }

</script>
</body>
</html>